package joyson.email.vo.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description:
 * @Author ke
 * @Date 2024/5/18 13:35
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T>{

    private Integer code;

    private T data;

    private String message;


    public static <T>Result<T> instance(Integer code, T data, String message){
        return new Result<>(code, data, message);
    }

    public static <T>Result<T> success(T data){
        return new Result<>(200, data, "success");
    }

    public static <T>Result<T> success(T data, String message){
        return new Result<>(200, data, message);
    }
    public static <T>Result<T> success(){
        return new Result<>(200, null, null);
    }

    public static <T>Result<T> failed(T data, String message){
        return new Result<>(400, data, message);
    }

    public static <T>Result<T> failed(){
        return new Result<>(400, null, "failed");
    }
}

